package com.gao.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class FileInputStreamDemo2 {
    /*
            字节读取数据
                    public int read(byte[] bys):读取一个字节数组
                            -将读取到的字节，存入数组容器，返回读取到的有效字节个数
     */
    public static void main(String[] args) throws IOException {
        FileInputStream stream = new FileInputStream("E://A.text");
        byte[] bys = new byte[2];
        int len;
        while((len=stream.read(bys))!=-1){
            String s= new String(bys,0,len);
            System.out.print(s);
        }
        stream.close();
    }
}
